<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>人员管理 - 七牛存储在线管理系统</title>
    <link rel="stylesheet" href="/static/css/layui.css">
    <style>
        .content {
            margin-top: 30px;
        }

        .top {
            width: 100%;
            height: 40px;
        }

        .top a {
            float: right;
        }

        .page {
            width: 100%;
            height: 40px;
        }

        .page ul {
            display: block;
            float: right;
        }

        .page ul a {
            display: block;
            float: left;
            padding: 0 12px;
            height: 30px;
            line-height: 30px;
            border-right: solid 1px #e6e6e6;
            border-top: solid 1px #e6e6e6;
            border-bottom: solid 1px #e6e6e6;
        }
        .page ul:first-child{
            border-left: solid 1px #e6e6e6;
        }
        .page ul strong{
            float: left;
            padding: 0 12px;
            height: 30px;
            line-height: 30px;
            border-top: solid 1px #1E9FFF;
            border-right: solid 1px #1E9FFF;
            border-bottom: solid 1px #e6e6e6;
            background-color: #1E9FFF;
            color: #FFF;
        }
    </style>
</head>
<body class="layui-layout-body">
<?php include './application/views/index/nav.php'; ?>
<div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
        <div class="position">
			<span class="layui-breadcrumb">
				<a href="/">首页</a>
				<a><cite>人员管理</cite></a>
			</span>
        </div>
        <div class="content">
            <div class="top">
                <a href="/user/add.html" class="layui-btn" title="添加">添加</a>
            </div>
            <table class="layui-table">
                <tbody>
                <tr>
                    <td width="50">序号</td>
                    <td>账户</td>
                    <td width="150">类型</td>
                    <td width="150">添加时间</td>
                    <td width="100">操作</td>
                </tr>
                <?php foreach ($data as $val): ?>
                    <tr>
                        <td><?php echo $val['id']; ?></td>
                        <td><?php echo $val['name']; ?></td>
                        <td><?php echo $val['type'] == 1 ? '用户' : '管理员'; ?></td>
                        <td><?php echo date('Y-m-d H:i:s', $val['intime']); ?></td>
                        <td>
                            <a href="/user/update.html?id=<?php echo $val['id']; ?>" title="修改"
                               class="layui-btn layui-btn-xs layui-btn-normal">修改</a>
                            <button data-id="<?php echo $val['id']; ?>" title="删除"
                                    class="delete layui-btn layui-btn-xs layui-btn-danger">删除
                            </button>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
            <?php echo $page; ?>
        </div>
    </div>
</div>
<div class="layui-footer">
    <!-- 底部固定区域 -->
    © Online-gallery系统
</div>
</div>
<script src="/static/layui.js"></script>
<script>
    layui.use(['element', 'jquery', 'layer'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        $(".delete").click(function () {
            var id = $(this).attr("data-id");
            if (!id) {
                layer.msg("无法获取参数");
            }
            $.ajax({
                data: {id: id},
                type: 'post',
                dataType: 'json',
                async: false,
                url: '/user/del.html',
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg(res.msg, {}, function () {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                },
                error: function () {
                    layer.msg("接口错误");
                }
            });
            return false;
        })
    });
</script>
</body>
</html>
